package com.example.mygrade.exception;


import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


@RestControllerAdvice
public class MyControllerAdvice {
    @ExceptionHandler(value = BindException.class)
    public String MethodArgumentNotValidExceptionHabdler(BindException exception){
        return exception.getBindingResult().getAllErrors().get(0).getDefaultMessage();
    }

}
